﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class SpecialMap : EntityConfigurationBase<Special>
    {
        public SpecialMap()
        {
            this.Property(p => p.Name).HasMaxLength(50).IsRequired();
            this.Property(p => p.Code).HasMaxLength(21).IsRequired();
            this.Property(p => p.ChargeName).HasMaxLength(20).IsRequired();
            this.Property(p => p.ChargePhone).HasMaxLength(11).IsRequired();
            this.Property(p => p.ChargePaperType).HasMaxLength(20).IsRequired();
            this.Property(p => p.ChargePaperNumber).HasMaxLength(30).IsRequired();
            this.Property(p => p.ChargeBank).HasMaxLength(30).IsRequired();
            this.Property(p => p.ChargeBankNumber).HasMaxLength(20).IsRequired();
            this.Property(p => p.CompanyBank).HasMaxLength(30).IsRequired();
            this.Property(p => p.CompanyNumber).HasMaxLength(20).IsRequired();
            this.Property(p => p.CreaterName).HasMaxLength(20).IsRequired();
            this.Property(p => p.UpdaterName).HasMaxLength(20).IsRequired();

            this.HasRequired(p => p.Creater).WithMany().HasForeignKey(f => f.CreaterId);
            this.HasRequired(p => p.Updater).WithMany().HasForeignKey(f => f.UpdaterId);
            this.HasRequired(p => p.Branch).WithMany().HasForeignKey(f => f.BranchId);

            this.HasRequired(p => p.SpecialCapital).WithRequiredPrincipal();
        }
    }
}
